﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="clr-namespace:Wpf.Controls"
    xmlns:classic="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic">

	<Style x:Key="ButtonFocusVisual">
		<Setter Property="Control.Template">
			<Setter.Value>
				<ControlTemplate>
					<Rectangle SnapsToDevicePixels="true" Margin="4" Stroke="Black" StrokeDashArray="1 2" StrokeThickness="1"/>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style x:Key="classicDropDownStyle" TargetType="{x:Type Button}">
		<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
		<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
		<Setter Property="BorderBrush" Value="{x:Static classic:ClassicBorderDecorator.ClassicBorderBrush}"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Button}">
					<Grid Background="Transparent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
						<classic:ClassicBorderDecorator x:Name="chrome" 
							HorizontalAlignment="Stretch" 
							VerticalAlignment="Stretch"
							Background="{TemplateBinding Background}"
							BorderBrush="{TemplateBinding BorderBrush}"
							BorderThickness="{TemplateBinding BorderThickness}"
							SnapsToDevicePixels="True">

							<ContentPresenter x:Name="Cp" HorizontalAlignment="Center" VerticalAlignment="Center"/>
						</classic:ClassicBorderDecorator>
					</Grid>

					<ControlTemplate.Triggers>
						<Trigger Property="IsPressed" Value="true">
							<Setter Property="BorderStyle" TargetName="chrome" Value="RaisedPressed"/>
							<Setter Property="Visibility" TargetName="chrome" Value="Visible"/>
						</Trigger>
						<Trigger Property="ToggleButton.IsChecked" Value="true">
							<Setter Property="BorderStyle" TargetName="chrome" Value="RaisedPressed"/>
						</Trigger>
						<Trigger Property="IsEnabled" Value="false">
							<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
						</Trigger>
						<Trigger Property="IsEnabled" Value="false">
							<Setter Property="Path.Stroke" TargetName="Cp" Value="#ADADAD"/>
							<Setter Property="Path.Fill" TargetName="Cp" Value="#ADADAD"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style TargetType="{x:Type s:SplitButton}">
		<Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
		<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
		<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
		<Setter Property="BorderBrush" Value="{x:Static classic:ClassicBorderDecorator.ClassicBorderBrush}"/>
		<Setter Property="BorderThickness" Value="3"/>
		<Setter Property="HorizontalContentAlignment" Value="Center"/>
		<Setter Property="VerticalContentAlignment" Value="Center"/>
		<Setter Property="Padding" Value="0"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type s:SplitButton}">
					<classic:ClassicBorderDecorator x:Name="buttonChrome" 
							HorizontalAlignment="Stretch" 
							VerticalAlignment="Stretch"
							BorderBrush="{TemplateBinding BorderBrush}"
							Background="{TemplateBinding Background}"
							BorderThickness="{TemplateBinding BorderThickness}"
							SnapsToDevicePixels="True">

						<Grid Background="Transparent" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
							<Grid.ColumnDefinitions >
								<ColumnDefinition Width="*"/>
								<ColumnDefinition Width="16"/>
							</Grid.ColumnDefinitions>

							<Border x:Name="Bd" Margin="1,1,2,1">
								<ContentPresenter
									HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
									VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
									Margin="{TemplateBinding Padding}"
									RecognizesAccessKey="True"
								/>
							</Border>

							<Path x:Name="path"
								Data="M0,0L3,3 6,0z" 
								Margin="4,1,0,0" 
								Grid.Column="1"
								Stroke="{TemplateBinding Foreground}" 
								Fill="{TemplateBinding Foreground}" 
								HorizontalAlignment="Center" 
								VerticalAlignment="Center"
								/>

							<Button x:Name="PART_DropDown"
								BorderBrush="{TemplateBinding BorderBrush}"
								Background="{TemplateBinding Background}"
								BorderThickness="{TemplateBinding BorderThickness}"
								Foreground="{TemplateBinding Foreground}"
								VerticalAlignment="Stretch"
								HorizontalAlignment="Stretch"
								Grid.Column="1"
								Margin="1,-3,-3,-3"
								Style="{DynamicResource classicDropDownStyle}"
								Opacity="0">

								<Path Data="M0,0L3,3 6,0z" Margin="0,1,0,0" Stroke="{TemplateBinding Foreground}" Fill="{TemplateBinding Foreground}"/>
							</Button>
						</Grid>
					</classic:ClassicBorderDecorator>
					<ControlTemplate.Triggers>
						<Trigger Property="IsKeyboardFocused" Value="true">
							<Setter Property="BorderStyle" TargetName="buttonChrome" Value="RaisedFocused"/>
						</Trigger>
						<Trigger Property="IsContextMenuOpen" Value="true">
							<Setter Property="BorderStyle" TargetName="buttonChrome" Value="RaisedPressed"/>
						</Trigger>
						<Trigger Property="ToggleButton.IsChecked" Value="true">
							<Setter Property="BorderStyle" TargetName="buttonChrome" Value="RaisedPressed"/>
						</Trigger>
						<Trigger Property="IsEnabled" Value="false">
							<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
						</Trigger>
						<Trigger Property="IsMouseOver" SourceName="PART_DropDown" Value="True">
							<Setter Property="Opacity" TargetName="PART_DropDown" Value="1"/>
						</Trigger>
						<Trigger Property="Mode" Value="Dropdown">
							<Setter Property="Visibility" TargetName="PART_DropDown" Value="Collapsed"/>
						</Trigger>
						<Trigger Property="Mode" Value="Button">
							<Setter Property="Visibility" TargetName="PART_DropDown" Value="Collapsed"/>
							<Setter Property="Visibility" TargetName="path" Value="Collapsed"/>
							<Setter Property="Grid.ColumnSpan" TargetName="Bd" Value="2"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>
